<!DOCTYPE html>
<html lang='en'>
<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script src='../vue.js'></script>
</head>
<body>
    <div id='app'>
        <h1>{{ishot?'热啊':'冷啊'}}</h1>
        <button @click="ishot=!ishot">change</button>
    </div>
    <script>
        Vue.config.productionTip = false;
        const vm = new Vue({
            el:'#app',
            data(){
                return {
                ishot:true
            }
            }
    })

    /* 
        在vue实例vm上有一个$watch方法,也可以处理对vm实例上的属性进行监听
            vm.$watch传的第一个参数不要忘了加引号了

            参数1:被监听的属性  
            参数2回调函数
            参数3:配置对象 deep immediate
    */
        vm.$watch(
            'ishot',
            ()=>{
                console.log('监听有更新了');
            },
            {
                immediate:true
            }
        )
    </script>
</body>
</html>